package com.liyuan.yiqixing.dao;

import com.liyuan.yiqixing.model.Signup;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

@Mapper
@Repository
public interface SignupDao {
    @Select("select id from signup where userId = #{userId} and itemId = #{itemId}")
    Integer selectSignupId(@Param("userId") Integer userId,
                           @Param("itemId") Integer itemId);

    @Insert("insert into signup(userId,itemId,hostelId) values(#{userId} ,#{itemId},#{hostelId})")
    void signup(@Param("userId") Integer userId,
                @Param("itemId") Integer itemId,
                @Param("hostelId")Integer hostelId);

    @Select("select * from signup where userId = #{userId}")
    Signup[] selectSignupInfos(Integer userId);

    @Select("select * from signup where hostelId = #{hostelId}")
    Signup[] selectSignupInfosByHostelId(@Param("hostelId") Integer hostelId);


    @Update("update  signup set status = 0 where id = #{signupId}")
    void updateSignupStatusToNotAccept(@Param("signupId") Integer signupId);

    @Update("update  signup set status = 1 where id = #{signupId}")
    void updateSignupStatusToAccept(@Param("signupId") Integer signupId);

}
